﻿using System;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;

namespace YArchitech.Revit
{
	[Transaction(TransactionMode.Manual)]
	[Regeneration(RegenerationOption.Manual)]
	public class SystemSearchCmd : IExternalCommand
	{
		public Result Execute(ExternalCommandData cmdData, ref string message, ElementSet elements)
		{
			UIDocument activeUIDocument = cmdData.Application.ActiveUIDocument;
			SearchSystem searchSystem = new SearchSystem(activeUIDocument, SearchSystemFilter.ByType);
			if (!searchSystem.Run(""))
			{
				TaskDialog.Show("盈建科提示", searchSystem.ErrorMessage);
				return Autodesk.Revit.UI.Result.Failed;
			}
			if (searchSystem.Save())
			{
				TaskDialog.Show("盈建科提示", "保存文件成功!");
				return Autodesk.Revit.UI.Result.Succeeded;
			}
			TaskDialog.Show("盈建科提示", searchSystem.ErrorMessage);
			return Autodesk.Revit.UI.Result.Failed;
		}
	}
}
